<?php
class Noticias_model extends CI_Model
{
    public function __construct()
    {
        parent::__construct();
        $this->load->database();
    }
     
    public function get_noticias($per_page,$segmento)
    {
        //$sql = $this->db->get('news',$per_page,$segmento);
        $sql = $this->db->query("SELECT * FROM news as a, news_tipo as b WHERE a.id_news_tipo=b.id_news_tipo  ORDER BY a.id LIMIT $segmento,$per_page");
        return $sql->result_array();
    }

    public function total_filas()
    {
        $sql = $this->db->get('news');
        return $sql->num_rows();
    }

    public function get_noticia($id)
    {
        $sql = $this->db->get_where('news', array('id' => $id));
        return $sql->result_array();
    }

    public function get_noticias_tipo()
    {
        //$sql = $this->db->get('news',$per_page,$segmento);
        $sql = $this->db->query("SELECT * FROM news_tipo ORDER BY tipo");
        return $sql->result_array();
    }

}
?>